<template>
  <div>
    <!--引用表格-->
   <BasicTable @register="registerTable" :rowSelection="rowSelection">
     <!--插槽:table标题-->
      <template #tableTitle>
      </template>
       <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)"/>
      </template>
      <!--字段回显插槽-->
      <template v-slot:bodyCell="{ column, record, index, text }">
      </template>
    </BasicTable>
    <!-- 表单区域 -->
    <CsPurchaseCourseOrderModal @register="registerModal" @success="handleSuccess"></CsPurchaseCourseOrderModal>
  </div>
</template>

<script lang="ts" name="cspurchasecourseorder-csPurchaseCourseOrder" setup>
  import {ref, reactive, computed, unref} from 'vue';
  import {BasicTable, useTable, TableAction} from '/@/components/Table';
  import {useModal} from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage'
  import CsPurchaseCourseOrderModal from './components/CsPurchaseCourseOrderModal.vue'
  import {approvalsCourseColumns, searchApprovalsFormSchema, superQuerySchema} from './CsPurchaseCourseOrder.data';
  import {queryPageOrderlList, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CsPurchaseCourseOrder.api';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import { useUserStore } from '/@/store/modules/user';
  const queryParam = reactive<any>({});
  const checkedKeys = ref<Array<string | number>>([]);
  const userStore = useUserStore();
  //注册model
  const [registerModal, {openModal}] = useModal();
  //注册table数据
  const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
      tableProps:{
           title: '购买课程订单表',
           api: queryPageOrderlList,
           columns :approvalsCourseColumns,
           canResize:false,
           formConfig: {
              //labelWidth: 120,
              schemas: searchApprovalsFormSchema,
              autoSubmitOnEnter:true,
              showAdvancedButton:true,
              fieldMapToNumber: [
              ],
              fieldMapToTime: [
                 ['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD'],
              ],
            },
           actionColumn: {
               width: 120,
               fixed:'right'
            },
            beforeFetch: (params) => {
              queryParam.nusubStatus='1'
              return Object.assign(params, queryParam);
            },
      },
       exportConfig: {
            name:"购买课程订单表",
            url: getExportUrl,
            params: queryParam,
          },
          importConfig: {
            url: getImportUrl,
            success: handleSuccess
          },
  })

  const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext


 
   /**
    * 审批详情
   */
  function handleDetail(record: Recordable) {
     openModal(true, {
       record,
       isUpdate: true,
       showFooter: false,
     });
   }
   
   /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }
   /**
      * 操作栏
      */
  function getTableAction(record){
       return [
        {
           label: '科目单',
           onClick: handleDetail.bind(null, record),
         }
       ]
   }
    


</script>

<style scoped>

</style>